package com.killer.auth.controller;

import com.killer.common.entity.Result;
import com.killer.auth.entity.AuthToken;
import com.killer.auth.service.IAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
public class AuthController {

    //客户端ID
    @Value("${auth.clientId}")
    private String clientId;
    //秘钥
    @Value("${auth.clientSecret}")
    private String clientSecret;
    @Autowired
    private IAuthService authService;

    @PostMapping("/login")
    public Result login(String username, String password) {
        //申请令牌
        AuthToken authToken = authService.login(username, password, clientId, clientSecret);
        return Result.success(authToken);
    }
}
